package leetcode;

/**
 * Created with IntelliJ IDEA.
 * Description:101. 对称二叉树
 * User: 东莞呵呵
 * Date:2022-07-20
 * Time:17:59
 */
public class TestDemo5 {
    public boolean isSymmetric(TreeNode root) {
        if(root==null){
            return true;
        }
        return isSymmetricChild(root.left,root.right);
    }
    public boolean isSymmetricChild(TreeNode left,TreeNode right){
        if (left==null&&right==null){
            return true;
        }
        if(left==null&&right!=null||right==null&&left!=null||left.val!= right.val){
            return false;
        }
        return isSymmetricChild(left.left,right.right)&&isSymmetricChild(left.right,right.left);
    }
}
